Skip to content

Support for explicit public API markers #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 3, 2023
Merged

Conversation

KirpichenkovPavel
Copy link
Contributor

The pull request introduces support for two new features:

  • Explicit public markers. Existing properties ignoredProjects, ignoredPackages and nonPublicMarkers allow excluding some parts of API from compatibility validation and checking the rest. New publicMarkers, publicPackages and publicClasses do the opposite: if any of them is used, only explicitly marked declarations are considered for validation, all the rest are excluded.
  • Adding extra Gradle source sets to check for Kotlin-JVM project. Without this change only the main source set can be validated.

Motivation

In kotlin.git we would like to maintain binary compatibility only for a few parts of the :kotlin-gradle-plugin project related to the External Kotlin Target API, that will be used by third parties when implemented. The declarations are either annotated, or belong to a specific package. Use of the existing API of validator to exclude everything else is not very convenient and would complicate maintenance of the project in the future. Because, for instance, adding new packages would require build script changes, as they have to be excluded from validation. Parts of the relevant code belong to a custom Gradle source set, so without the second introduced feature validation is not possible.

Implementation notes

  • Explicit marker mode only affects validation if any of the new public* properties are used in a build script, which shouldn't affect any users that don't touch the properties
  • Explicit declaration filtering happens before the usual filtering of ignored projects, packages and marked non-public declarations. This makes it possible to combine two modes, e.g. filter out marked non-public members of a class from a public package
  • In case of clashes, when the same declaration is both ignored and explicitly public at the same time, ignored "wins"
  • Listing extra source sets for validation is only supported for projects with the kotlin-jvm Gradle plugin to minimize the changes

If the added properties are used, all unmatched declarations will be excluded
from the API check. If properties for both ignored and explicit markers are set,
filtering of ignored declarations will happen after filtering of declarations
not explicitly marked as public.
.map { it.flattenNonPublicBases() }
.filterNot { it.isNotUsedWhenEmpty && it.memberSignatures.isEmpty() }
}

@ExternalApi
public fun List<ClassBinarySignature>.retainExplicitlyIncludedIfDeclared(
Copy link
Member

@qwwdfsad qwwdfsad Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please elaborate on whether you do plan to use retainExplicitlyIncludedIfDeclared exclusively or also plugin DSL to use the API?

@qwwdfsad qwwdfsad self-requested a review March 3, 2023 13:37
Copy link
Member

@qwwdfsad qwwdfsad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done!

@qwwdfsad qwwdfsad merged commit 5d08f51 into master Mar 3, 2023
@qwwdfsad qwwdfsad deleted the pk/public-markers branch March 3, 2023 13:43
github-merge-queue bot referenced this pull request in elide-dev/elide Jul 23, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[org.jetbrains.kotlinx.binary-compatibility-validator](https://togithub.com/Kotlin/binary-compatibility-validator)
| `0.12.1` -> `0.13.2` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/org.jetbrains.kotlinx.binary-compatibility-validator/0.13.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/org.jetbrains.kotlinx.binary-compatibility-validator/0.13.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/org.jetbrains.kotlinx.binary-compatibility-validator/0.12.1/0.13.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/org.jetbrains.kotlinx.binary-compatibility-validator/0.12.1/0.13.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
|
[org.jetbrains.kotlinx:binary-compatibility-validator](https://togithub.com/Kotlin/binary-compatibility-validator)
| `0.12.1` -> `0.13.2` |
[![age](https://developer.mend.io/api/mc/badges/age/maven/org.jetbrains.kotlinx:binary-compatibility-validator/0.13.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/org.jetbrains.kotlinx:binary-compatibility-validator/0.13.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/org.jetbrains.kotlinx:binary-compatibility-validator/0.12.1/0.13.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/org.jetbrains.kotlinx:binary-compatibility-validator/0.12.1/0.13.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### ⚠ Dependency Lookup Warnings ⚠

Warnings were logged while processing this repo. Please check the
Dependency Dashboard for more information.

---

### Release Notes

<details>
<summary>Kotlin/binary-compatibility-validator
(org.jetbrains.kotlinx.binary-compatibility-validator)</summary>

###
[`v0.13.2`](https://togithub.com/Kotlin/binary-compatibility-validator/releases/tag/0.13.2)

[Compare
Source](https://togithub.com/Kotlin/binary-compatibility-validator/compare/0.13.1...0.13.2)

-   `kotlinx-metadata` is updated to 0.6.2 with the support of LV 2.0

###
[`v0.13.1`](https://togithub.com/Kotlin/binary-compatibility-validator/releases/tag/0.13.1)

[Compare
Source](https://togithub.com/Kotlin/binary-compatibility-validator/compare/0.13.0...0.13.1)

- Added support for explicit public API markers
([https://github.com/Kotlin/binary-compatibility-validator/pull/116](https://togithub.com/Kotlin/binary-compatibility-validator/pull/116))

###
[`v0.13.0`](https://togithub.com/Kotlin/binary-compatibility-validator/releases/tag/0.13.0)

[Compare
Source](https://togithub.com/Kotlin/binary-compatibility-validator/compare/0.12.1...0.13.0)

-   Kotlin is updated to 1.8.10
-   kotlinx-metadata is updated to 0.6.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/elide-dev/elide).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi4xMS4wIiwidXBkYXRlZEluVmVyIjoiMzYuMTEuMCIsInRhcmdldEJyYW5jaCI6InYzIn0=-->
shanshin pushed a commit to JetBrains/kotlin that referenced this pull request Oct 28, 2024
* Add support for defining public declarations explicitly

If the added properties are used, all unmatched declarations will be excluded
from the API check. If properties for both ignored and explicit markers are set,
filtering of ignored declarations will happen after filtering of declarations
not explicitly marked as public.

* Support validation of non-main source sets for kotlin-jvm projects
Pull request Kotlin/binary-compatibility-validator#116
shanshin pushed a commit to JetBrains/kotlin that referenced this pull request Dec 3, 2024
* Add support for defining public declarations explicitly

If the added properties are used, all unmatched declarations will be excluded
from the API check. If properties for both ignored and explicit markers are set,
filtering of ignored declarations will happen after filtering of declarations
not explicitly marked as public.

* Support validation of non-main source sets for kotlin-jvm projects
Pull request Kotlin/binary-compatibility-validator#116
shanshin pushed a commit to JetBrains/kotlin that referenced this pull request Dec 13, 2024
* Add support for defining public declarations explicitly

If the added properties are used, all unmatched declarations will be excluded
from the API check. If properties for both ignored and explicit markers are set,
filtering of ignored declarations will happen after filtering of declarations
not explicitly marked as public.

* Support validation of non-main source sets for kotlin-jvm projects
Pull request Kotlin/binary-compatibility-validator#116
shanshin pushed a commit to JetBrains/kotlin that referenced this pull request Dec 23, 2024
* Add support for defining public declarations explicitly

If the added properties are used, all unmatched declarations will be excluded
from the API check. If properties for both ignored and explicit markers are set,
filtering of ignored declarations will happen after filtering of declarations
not explicitly marked as public.

* Support validation of non-main source sets for kotlin-jvm projects
Pull request Kotlin/binary-compatibility-validator#116

Moved from Kotlin/binary-compatibility-validator@5d08f51
KotlinBuild pushed a commit to JetBrains/kotlin that referenced this pull request Jan 3, 2025
* Add support for defining public declarations explicitly

If the added properties are used, all unmatched declarations will be excluded
from the API check. If properties for both ignored and explicit markers are set,
filtering of ignored declarations will happen after filtering of declarations
not explicitly marked as public.

* Support validation of non-main source sets for kotlin-jvm projects
Pull request Kotlin/binary-compatibility-validator#116

Moved from Kotlin/binary-compatibility-validator@5d08f51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants